package reflection.equals.correct;



import org.junit.Assert;
import org.junit.Test;

public class EqualsTest {

	
	@Test
	public void allWithNull(){
		long id = 1L;
		Order order = new Order(id);
		Customer customer = new Customer(id);
		VipOrder vipOrder = new VipOrder(id);
		
		Assert.assertFalse(order.equals(null));
		Assert.assertFalse(customer.equals(null));
		Assert.assertFalse(vipOrder.equals(null));
	}
	
	@Test
	public void theSameObject()
	{
		long id = 1L;
		Order order = new Order(id);
		Customer customer = new Customer(id);
		VipOrder vipOrder = new VipOrder(id);
		
		Assert.assertTrue(order.equals(order));
		Assert.assertTrue(customer.equals(customer));
		Assert.assertTrue(vipOrder.equals(vipOrder));
	}
	
	
	
	
	@Test
	public void twoEqualsObjects()
	{
		long id = 1L;
		Order order1 = new Order(id);
		Order order2 = new Order(id);
		
		Customer customer1 = new Customer(id);
		Customer customer2 = new Customer(id);
		
		VipOrder vipOrder1 = new VipOrder(id);
		VipOrder vipOrder2 = new VipOrder(id);
		
		Assert.assertTrue(order1.equals(order2));
		Assert.assertTrue(customer1.equals(customer2));
		Assert.assertTrue(vipOrder1.equals(vipOrder2));
	}
	
	@Test
	public void twoNotEqualsObjects()
	{
		
		long id1 = 1L;
		long id2 = 2L;
		Order order1 = new Order(id1);
		Order order2 = new Order(id2);
		
		Customer customer1 = new Customer(id1);
		Customer customer2 = new Customer(id2);
		
		VipOrder vipOrder1 = new VipOrder(id1);
		VipOrder vipOrder2 = new VipOrder(id2);
		
		Assert.assertFalse(order1.equals(order2));
		Assert.assertFalse(customer1.equals(customer2));
		Assert.assertFalse(vipOrder1.equals(vipOrder2));
	}
	
	@Test
	public void orderAndOrderDiffObjects()
	{
		long id = 1L;
		Order order = new Order(id);
		Customer customer = new Customer(id);
		VipOrder vipOrder = new VipOrder(id);
		
		Assert.assertFalse(order.equals(customer));
		Assert.assertFalse(order.equals(vipOrder));
		
		
	}
}
